﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EasyPiano
{
    public partial class InputMusicRecordDataForm : Form
    {
        public MusicRecord record;
        public InputMusicRecordDataForm()
        {
            InitializeComponent();
            fbd_path.SelectedPath = System.Environment.CurrentDirectory + "\\Record";
            tb_path.Text = fbd_path.SelectedPath;
        }

        private void bt_save_Click(object sender, EventArgs e)
        {
            string path = tb_path.Text + "\\" + tb_musicName.Text + ".xml";
            if (path != "")
            {
                record.musicName = tb_musicName.Text;
                record.author = tb_author.Text;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
                record.Save(path);
                MessageBox.Show("保存成功！");
            }
        }

        private void bt_listen_Click(object sender, EventArgs e)
        {
            MusicRecordManagerForm form = new MusicRecordManagerForm();
            record.musicName = tb_musicName.Text;
            record.author = tb_author.Text;
            form.record = record;
            form.Show();
        }

        private void tb_path_MouseDown(object sender, MouseEventArgs e)
        {
            if (fbd_path.ShowDialog() == DialogResult.OK)
            {
                string path = fbd_path.SelectedPath;
                tb_path.Text = path;
            }
        }
    }
}
